<?php

class Application_Form_Membro extends Zend_Form
{

    public function init()
    {
        $this->setName('membro');
        $id = new Zend_Form_Element_Hidden('idmembro');
        $id->addFilter('Int');
        
        $nome = new Zend_Form_Element_Text('nome');
        $nome->setLabel('Nome')
            ->setRequired(true)
            ->addFilter('StripTags')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty')
            ->setOptions(array('class'=>'form-control'));

        $rg = new Zend_Form_Element_Text('rg');
        $rg->setLabel('RG')
            ->setRequired(false)
            ->addFilter('StripTags')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty')
            ->setOptions(array('class'=>'form-control'));
            
        $cpf = new Zend_Form_Element_Text('cpf');
        $cpf->setLabel('CPF')
            ->setRequired(false)
            ->addFilter('StripTags')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty')
            ->setOptions(array('class'=>'form-control'));
        
        $endereco = new Zend_Form_Element_Text('endereco');
        $endereco->setLabel('Endereco')
            ->setRequired(false)
            ->addFilter('StripTags')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty')
            ->setOptions(array('class'=>'form-control'));

        $cep = new Zend_Form_Element_Text('cep');
        $cep->setLabel('CEP')
            ->setRequired(false)
            ->addFilter('StripTags')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty')
            ->setOptions(array('class'=>'form-control'));
        
        $dt_nascimento = new Zend_Form_Element_Text('dt_nascimento');
        $dt_nascimento->setLabel('Data de Nascimento')
            ->setRequired(false)
            ->addFilter('StripTags')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty')
            ->setOptions(array('class'=>'form-control'));
        
        $dt_batismo = new Zend_Form_Element_Text('dt_batismo');
        $dt_batismo->setLabel('Data de Batismo')
            ->setRequired(false)
            ->addFilter('StripTags')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty')
            ->setOptions(array('class'=>'form-control'));
        
        $tel_residencial = new Zend_Form_Element_Text('tel_residencial');
        $tel_residencial->setLabel('Telefone Residencial')
            ->setRequired(false)
            ->addFilter('StripTags')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty')
            ->setOptions(array('class'=>'form-control'));
        
        $tel_celular = new Zend_Form_Element_Text('tel_celular');
        $tel_celular->setLabel('Telefone Celular')
            ->setRequired(false)
            ->addFilter('StripTags')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty')
            ->setOptions(array('class'=>'form-control'));
        
        $email = new Zend_Form_Element_Text('email');
        $email->setLabel('Email')
            ->setRequired(false)
            ->addFilter('StripTags')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty')
            ->setOptions(array('class'=>'form-control'));
        
        /*$sexo = new Zend_Form_Element_Text('sexo');
        $sexo->setLabel('Sexo')
            ->setRequired(false)
            ->addFilter('StripTags')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty')
            ->setOptions(array('class'=>'form-control'));*/
        
        $sexo = $this->createElement  ('radio','sexo',array('label'=>'Sexo'));
        $sexo->setRequired(false)
            ->setMultiOptions(array('m'=>' Masculino','f'=>' Feminino'))
            ->setOptions(array('class'=>'radio-inline')) 
            ->addDecorator('HtmlTag',array('tag' => 'div', 'class' => 'form-group'))
                ;

               
        $idtipo_situacao = new Zend_Form_Element_Text('idtipo_situacao');
        $idtipo_situacao->setLabel('Situacao')
            ->setRequired(false)
            ->addFilter('StripTags')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty')
            ->setOptions(array('class'=>'form-control'));  
        
        $situacoes = new Application_Model_DbTable_Situacao();            
        $sits =  $situacoes->fetchAll(null,'situacao'); 
       // echo '<pre>'; var_dump($sits);die;
 
        
        $situacao = new Zend_Form_Element_Select('idtipo_situacao');
        $situacao->setLabel('Situacao')
             ->setOptions(array('class'=>'form-control'))
             //->setMultiOptions($_situacaoOptions)
             ->setRequired(true)->addValidator('NotEmpty', true);
        foreach ($sits as $sit):
             $situacao->addMultiOption($sit->idtipo_situacao, $sit->situacao);
        endforeach;
                
        $submit = new Zend_Form_Element_Submit('submit');
        $submit -> setOptions(array('class'=>'btn btn-primary'));
        $submit->setAttrib('idtipo_situacao', 'submitbutton');
        
        
       $this->addElements(array($id, $nome, $rg, $cpf,$endereco,$cep, $dt_nascimento, 
            $dt_batismo,$tel_residencial,$tel_celular,$email,$sexo,$situacao, $submit));
        
        $this->addDisplayGroup(array($nome, $rg, $cpf,$endereco,$cep, $sexo), 'myDisplayGroup');
        
        $this->addDisplayGroup(array($dt_nascimento, $dt_batismo,$tel_residencial,$tel_celular,$email,$idtipo_situacao, 
            $submit), 'myDisplayGroup2');
        
        $group = $this->getDisplayGroup('myDisplayGroup');
        $group2 = $this->getDisplayGroup('myDisplayGroup2');

        $group->setDecorators(array(
           'FormElements',
           array('HtmlTag', array('tag' => 'div', 'class' => 'col-lg-6'))
        ));
        
        $group2->setDecorators(array(
           'FormElements',
           array('HtmlTag', array('tag' => 'div', 'class' => 'col-lg-6'))
        ));
        
    }


}

